"use strict";

const expect = require("chai").expect;
const path = require("path");

const Model = require(path.join("..", "..", "..", "app", "models", "model"));
const petData = require(path.join("..", "..", "..", "fixtures", "database")).pet;

describe("models/Model", function() {
  let subject = new Model("pet");
  it("#initialize", function() {
    expect(subject).to.be.instanceOf(Model);
  });
  it("#constructor", function() {
    expect(subject.tableName).to.be.ok;
  });
  it("#store", function(done) {
    subject.clearCache()
      .then(() => subject.store(petData))
      .then(function(result) {
        expect(result).to.not.be.empty;
        done();
      });
  });
  it("#isInCache", function(done) {
    subject.clearCache()
      .then(() => subject.store(petData))
      .then(() => subject.isInCache(petData))
      .then(function(result) {
        expect(result).to.have.keys("id",
                                    "name",
                                    "created_at",
                                    "updated_at");
        done();
      });
  });
});
